package m.store.model;

import m.base.model.StoreInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "ts_guest_amount_link", description = "客户金额关联")
public class GuestAmountLink extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("backAmount.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="back_amount_oid",table= GuestBackAmount.class,description="所属到款")
    private GuestBackAmount backAmount;
    @FieldMeta(name="link_amount",type= FieldType.DOUBLE,defaultValue = "0",description="关联金额")
    private Double linkAmount;
    @LinkTableMeta(name="income_oid",table= IncomeAmount.class,description="收款")
    private IncomeAmount income;
    @LinkTableMeta(name="pay_oid",table= PayAmount.class,description="付款")
    private PayAmount pay;

    public GuestBackAmount getBackAmount() {
        return backAmount;
    }

    public void setBackAmount(GuestBackAmount backAmount) {
        this.backAmount = backAmount;
    }

    public Double getLinkAmount() {
        return linkAmount;
    }

    public void setLinkAmount(Double linkAmount) {
        this.linkAmount = linkAmount;
    }

    public IncomeAmount getIncome() {
        return income;
    }

    public void setIncome(IncomeAmount income) {
        this.income = income;
    }

    public PayAmount getPay() {
        return pay;
    }

    public void setPay(PayAmount pay) {
        this.pay = pay;
    }
}
